home *** CD-ROM | disk | FTP | other *** search
/ ETO Development Tools 4 / ETO Development Tools 4.iso / Tools - Objects / MPW C++ / MPW C++ 3.1 / Interfaces / CIncludes / iomanip.h < prev    next >
Text File  |  1990-09-11  |  3KB  |  116 lines

  1. /*ident    "@(#)ctrans:incl/iomanip.h    1.1.2.2" */
  2. /**************************************************************************
  3.                         Copyright (c) 1984 AT&T
  4.                           All Rights Reserved   
  5.  
  6.         THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF AT&T
  7.       
  8.         The copyright notice above does not evidence any        
  9.         actual or intended publication of such source code.
  10.  
  11. *****************************************************************************/
  12.  
  13. #ifndef __IOMANIP__
  14. #define __IOMANIP__
  15.  
  16. #include <generic.h>
  17.  
  18. #define SMANIP(T)name2(smanip_,T)
  19. #define SAPP(T)name2(sapply_,T)
  20. #define IMANIP(T)name2(imanip_,T)
  21. #define OMANIP(T)name2(omanip_,T)
  22. #define IOMANIP(T)name2(iomanip_,T)
  23. #define IAPP(T)name2(iapply_,T)
  24. #define OAPP(T)name2(oapply_,T)
  25. #define IOAPP(T)name2(ioapply_,T)
  26.  
  27. #define IOMANIPdeclare(T)                        \
  28. class SMANIP(T) {                            \
  29.     ios& (*fct)(ios&,T) ;                        \
  30.     T arg ;                                \
  31. public:                                    \
  32.     SMANIP(T)(ios& (*f)(ios&, T), T a) :                \
  33.             fct(f), arg(a) { }                \
  34.     friend istream& operator>>(istream& i, SMANIP(T)& m) {        \
  35.             ios* s = &i ;                    \
  36.             (*m.fct)(*s,m.arg) ; return i ; }        \
  37.     friend ostream& operator<<(ostream& o, SMANIP(T)& m) {        \
  38.             ios* s = &o ;                    \
  39.             (*m.fct)(*s,m.arg) ; return o ; }        \
  40.     } ;                                \
  41. class SAPP(T) {                                \
  42.     ios& (*fct)(ios&, T) ;                        \
  43. public:                                    \
  44.     SAPP(T)(ios& (*f)(ios&,T)) : fct(f) { }                \
  45.     SMANIP(T) operator()(T a) {                    \
  46.             return SMANIP(T)(fct,a) ; }            \
  47.     } ;                                \
  48. class IMANIP(T) {                            \
  49.     istream& (*fct)(istream&,T) ;                    \
  50.     T arg ;                                \
  51. public:                                    \
  52.     IMANIP(T)(istream& (*f)(istream&, T), T a ) :            \
  53.         fct(f), arg(a) { }                    \
  54.     friend istream& operator>>(istream& s, IMANIP(T)& m) {        \
  55.         return(*m.fct)(s,m.arg) ;                \
  56.         }                            \
  57.     } ;                                \
  58. class IAPP(T) {                                \
  59.     istream& (*fct)(istream&, T) ;                    \
  60. public:                                    \
  61.     IAPP(T)(istream& (*f)(istream&,T)) : fct(f) { }            \
  62.     IMANIP(T) operator()(T a) {                    \
  63.             return IMANIP(T)(fct,a) ; }            \
  64.     } ;                                \
  65. class OMANIP(T) {                            \
  66.     ostream& (*fct)(ostream&,T) ;                    \
  67.     T arg ;                                \
  68. public:                                    \
  69.     OMANIP(T)(ostream& (*f)(ostream&, T), T a ) :            \
  70.         fct(f), arg(a) { }                    \
  71.     friend ostream& operator<<(ostream& s, OMANIP(T)& m) {        \
  72.         return(*m.fct)(s,m.arg) ;                \
  73.         }                            \
  74.     } ;                                \
  75. class OAPP(T) {                                \
  76.     ostream& (*fct)(ostream&, T) ;                    \
  77. public:                                    \
  78.     OAPP(T)(ostream& (*f)(ostream&,T)) : fct(f) { }            \
  79.     OMANIP(T) operator()(T a) {                    \
  80.             return OMANIP(T)(fct,a) ; }            \
  81.     } ;                                \
  82. class IOMANIP(T) {                            \
  83.     iostream& (*fct)(iostream&,T) ;                    \
  84.     T arg ;                                \
  85. public:                                    \
  86.     IOMANIP(T)(iostream& (*f)(iostream&, T), T a ) :        \
  87.         fct(f), arg(a) { }                    \
  88.     friend istream& operator>>(iostream& s, IOMANIP(T)& m) {    \
  89.         return(*m.fct)(s,m.arg) ;                \
  90.         }                            \
  91.     friend ostream& operator<<(iostream& s, IOMANIP(T)& m) {    \
  92.         return(*m.fct)(s,m.arg) ;                \
  93.         }                            \
  94.     } ;                                \
  95. class IOAPP(T) {                            \
  96.     iostream& (*fct)(iostream&, T) ;                \
  97. public:                                    \
  98.     IOAPP(T)(iostream& (*f)(iostream&,T)) : fct(f) { }        \
  99.     IOMANIP(T) operator()(T a) {                    \
  100.             return IOMANIP(T)(fct,a) ; }            \
  101.     } ;                                \
  102.  
  103.  
  104.  
  105. IOMANIPdeclare(int) ;
  106. IOMANIPdeclare(long) ;
  107.  
  108. SMANIP(int)     setbase(int b) ;    /* 10, 8, 16 or 0 */
  109. SMANIP(long)    resetiosflags(long b) ;
  110. SMANIP(long)    setiosflags(long b) ;
  111. SMANIP(int)    setfill(int f);
  112. SMANIP(int)    setprecision(int p);
  113. SMANIP(int)    setw(int w) ;
  114.  
  115. #endif
  116.